def get_lines():
    file = "searchResult.txt"
    with open(file, "r", encoding='UTF-8') as f:
        lines = f.readlines()
    return lines

def search_from_file_simple():
    file = "searchResult.txt"
    with open(file, "r", encoding='UTF-8') as f:
        # 显示起始值
        lines = f.readlines()
        listNum = lines[-1].strip().split("：")[1]
        # 查询结果， 0 条，1 条，多条 情况
        if int(listNum) == 0:
            first, end = "", ""
        elif int(listNum) == 1:
            first = lines[0].strip()
            end = "end"
            # first, end = lines[0].strip()
        elif int(listNum) > 1:
            first = lines[0].strip()
            end = lines[-2].strip()
    return first, end, listNum, lines


def search_from_file():
    file = "searchResult.txt"
    with open(file, "r", encoding='UTF-8') as f:
        # 显示起始值
        lines = f.readlines()
        listNum = 0
        first = ''
        end = ''
        errorinfo = ""
        if "error" in lines[0]:
            errorinfo = lines[0].strip()
            return first, end, listNum, errorinfo
        elif len(lines) == 1:
            first = lines
            return first, end, listNum, errorinfo
        else:
            listNum = lines[-1].strip().split("：")[1]
            # 查询结果， 0 条，1 条，多条 情况
            if int(listNum) == 0:
                first, end = "", ""
            elif int(listNum) == 1:
                first = end = lines[0].strip()
            elif int(listNum) > 1:
                first = lines[0:6]
                end = lines[-8:-2]
    return first, end, listNum, errorinfo

